package com.gutsyzhan.bilibili.controller;

import com.gutsyzhan.bilibili.domain.JsonResponse;
import com.gutsyzhan.bilibili.domain.auth.UserAuthorities;
import com.gutsyzhan.bilibili.service.UserAuthService;
import com.gutsyzhan.bilibili.support.UserSupport;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class UserAuthController {
    @Resource
    private UserSupport userSupport;

    @Resource
    private UserAuthService userAuthService;

    /**
     * 获取某个用户所有的权限
     * @return
     */
    @GetMapping("/user-authorities")
    public JsonResponse<UserAuthorities> getUserAuthorities(){
        Long userId = userSupport.getCurrentUserId();
        UserAuthorities userAuthorities = userAuthService.getUserAuthorities(userId);
        return new JsonResponse<>(userAuthorities);
    }
}
